#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
    int n;
    int arr[51] = { 0 };
    int m;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }
    scanf("%d", &m);
    int k = 0;
    for (int j = 0; j < n; j++)
    {
        if (m > arr[j])
        {
            k++;
            if (k == n)
            {
                arr[n] = m;
            }
        }
        else
        {
            int tmp = m;
            for (int i = k; i < n + 1; i++)
            {
                int h = arr[i];
                arr[i] = tmp;
                tmp = h;
            }
            break;
        }
    }
    for (int i = 0; i < n + 1; i++)
    {
        printf("%d ", arr[i]);
    }
    return 0;
}